/*
 *@author: YangJie
 *@date: 2021-04-16 16:13:34
 *@version:
 *@description:参数设置->设备参数设置->设备列表隐藏/显示
*/
import React, { Component } from 'react';
import { Button, Form, Switch, Tabs } from 'antd';
import '@/assets/css/settings';
const { TabPane } = Tabs;
const FormItem = Form.Item;

const deviceListDemo = [
	{ id: 1, key: 'a', value: 'a', name: '故障报修', status: true },
	{ id: 2, key: 'b', value: 'b', name: '维修计划', status: true },
	{ id: 3, key: 'c', value: 'c', name: '维修工单', status: true },
	{ id: 2, key: 'd', value: 'd', name: '保养计划', status: true },
	{ id: 2, key: 'e', value: 'e', name: '保养工单', status: true },
	{ id: 2, key: 'f', value: 'f', name: '备件更换记录', status: false },
	{ id: 2, key: 'g', value: 'g', name: '关联备件', status: false },
	{ id: 2, key: 'h', value: 'h', name: '关联文档', status: false },
	{ id: 2, key: 'i', value: 'i', name: '设备图片', status: false },
	{ id: 2, key: 'j', value: 'j', name: '设备履历', status: false }
];

class App extends Component {
	state = {
		loading: false, //加载中...
		chooseData: [],
		deviceListvalue: [],
		//设备状态列表
		deviceList: deviceListDemo
	};
	componentDidMount() {}
	//初始化加载数据
	fetch = data => {
		// this.setState({ loading: true })
		// this.post('/airCargo/pageList',{data}).then(res => {
		// 	this.setState({
		// 		loading: false,
		// 		dataSource: res.data.data,
		// 		total:res.data.total,
		// 		formValues:data
		// 	});
		// })
	};

	genDeviceStatusList = () => {
		const { getFieldDecorator } = this.props.form;
		const deviceList = this.state.deviceList;
		const itemList = [];
		deviceList.map(item => {
			const temp = (
				<FormItem>
					<Switch checkedChildren="显示" unCheckedChildren="隐藏" defaultChecked={item.status ? item.status : false} />
					<span style={{ paddingLeft: '10px' }}>{item.name}</span>
				</FormItem>
			);
			itemList.push(temp);
		});
		return itemList;
	};

	render() {
		const { chooseData, drawerVisible, drawerTitle, dataSource, loading, total, formValues } = this.state;

		return (
			<div className="shadow-radius">
				<Tabs>
					<TabPane tab="设备列表显示/隐藏" key="1">
						<Form layout="inline" style={{ width: '70%' }}>
							{this.genDeviceStatusList()}
							<FormItem style={{ display: 'block', marginTop: 10 }}>
								<Button type="primary" htmlType="submit" className={'btn'} onClick={this.saveDeviceList}>
									保存
								</Button>
							</FormItem>
						</Form>
					</TabPane>
				</Tabs>
			</div>
		);
	}
}
export default Form.create()(App);
